<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/29
 * Time: 7:41
 */
//如果用户同意授权，页面将跳转至 redirect_uri/?code=CODE&state=STATE。



$code = $_GET['code'];
//第二步 用获取的code 换去 网页授权的access_token
$appID = "wx94010b1eb2f5362d";
$appsecret = "51ac1f02b2cc1c5a643c85f908acb680";
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appID&secret=$appsecret&code=$code&grant_type=authorization_code";

$res = file_get_contents($url);
var_dump($res);